#ifndef AVIATION_FLIGHTNUMBER_H
#define AVIATION_FLIGHTNUMBER_H

#include "util.h"

#include <string>
#include <exception>

#include <boost/serialization/nvp.hpp>

namespace aviation
{

/// This class represents a flight number of form AB123.
class FlightNumber
{
public:

	typedef std::string String;

	// Constructors

	//Initialises flight number.
	FlightNumber();

	/// Creates a flight number from a string.
	/// \param fcgString A string containing the flight number from an FCGDATA file.
	FlightNumber(const String& fcgString);

	/// Destructs the flight number.
	~FlightNumber();

	/// Copies the flight number from another.
	FlightNumber(const FlightNumber& other);

	// Operators

	/// Assigns the contents of one flight number to another.
	FlightNumber& operator=(const FlightNumber& other);

	/// Tests for equality between two flight numbers.
	/// \returns true if the flight numbers are the same, or false if they are different.
	const bool operator==(const FlightNumber& other) const;

	/// Tests for inequality between two flight numbers.
	/// \returns true if the flight numbers are different, or false if they are the same.
	const bool operator!=(const FlightNumber& other) const;

	// Accessors

	/// Gets the flight number as a string.
	/// \returns the flight number formatted as a string.
	const String AsString() const;

	// Serialization

	/// Serialization (file I-O) function.
	/// \param ar A boost::archive formatter type.
	/// \param version The file version.
	template <class Archive>
	void serialize(Archive& ar, const unsigned int version);

private:

	char m_c1, m_c2;
	unsigned int m_number;
};

template <class Archive>
void FlightNumber::serialize(Archive& ar, const unsigned int version)
{
	ar & BOOST_SERIALIZATION_NVP(m_c1);
	ar & BOOST_SERIALIZATION_NVP(m_c2);
	ar & BOOST_SERIALIZATION_NVP(m_number);
}

} // namespace aviation

#endif // AVIATION_FLIGHTNUMBER_H
